package com.house.service;

import com.house.entity.Message;
import com.house.mapper.MessageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class MessageService {
    @Autowired
    private MessageMapper messageMapper;

    public void  insertOne(int userId,int toUserId,String content){
        Date date = new Date();
        messageMapper.insertOne(userId,toUserId,content,date);
    }

    public List<Message> findAllByToUserId(int toUserId){
        return messageMapper.findAllToUserId(toUserId);
    }
    public List<Message> findByToUserIdAndUserId(int userId,int toUserId){
        return messageMapper.findByToUserIdAndUserId(userId,toUserId);
    }

    public void deleteById(int id){
        messageMapper.deleteById(id);
    }
}
